#ifndef ACTIONLISTCONTROLLER_H
#define ACTIONLISTCONTROLLER_H

#include <QObject>

class QAbstractListModel;
class QModelIndex;

/**
 * This class holds the info of the active item of an \a ActionListView,
 * (i.e. the item that has playbar on).
 * When an item is moved or deleted, index of active item is changed accordingly.
 */
class ActionListController : public QObject
{
   Q_OBJECT
public:
   explicit ActionListController( QAbstractListModel & model, QObject *parent = 0);

   static const int NoItemActive = -1;

   int activeItemRow() const {
      return m_activeItemRow;
   }

   void shiftItemUp( int itemRow);
   void shiftItemDown( int itemRow);
   void removeItemsRequest(QList<QModelIndex> &indexList);

public slots:
   void activateRequest( const QModelIndex &item);
   void activateRequest( int itemRow);

signals:
   void activeRowChanged( int);
   void shiftedUp( int);
   void shiftedDown( int);

private:
   int m_activeItemRow;
   QAbstractListModel & m_model;

private slots:
   void onRowsRemoved(const QModelIndex &, int first, int last);
};

#endif // ACTIONLISTCONTROLLER_H
